package com.matrix.draft.helloworld.sys;

import javax.swing.*;
import java.awt.*;

public class SmartRobot extends Robot {

    public SmartRobot() throws AWTException {
        super();
    }

    @Override
    public synchronized void mouseMove(int x2, int y2) {
        Point currentPoint = MouseInfo.getPointerInfo().getLocation();
        double x1 = currentPoint.getX();
        double y1 = currentPoint.getY();
        final double t = 100;
        final double n = 100;
        double dx = (x2 - x1) / n;
        double dy = (y2 - y1) / n;
        double dt = t / n;
        try {
            for (int i = 1; i <= n; i++) {
                Thread.sleep((int) dt);
                super.mouseMove((int) (x1 + dx * i), (int) (y1 + dy * i));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


}
